//
//  HomeTableHeadView.m
//  RONGAO
//
//  Created by wei wang on 2017/2/22.
//  Copyright © 2017年 wei wang. All rights reserved.
//

#import "HomeTableHeadView.h"

@implementation HomeTableHeadView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
/*
+ (instancetype)headerViewWithTableView:(UITableView *)tableView{
    
    static NSString *ID = @"header";
    HomeTableHeadView *headView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:ID];

    if (headView == nil) {
        
        headView = [[HomeTableHeadView alloc] initWithReuseIdentifier:ID];
        
    }
    return headView;
}
*/

- (instancetype)init{
    
    if ([super init]) {
        
        [self masLayoutSubview];
        
    }
    
    return self;
}

- (void)masLayoutSubview{
    
    __weak UIView *superView = self;
    __weak typeof(self) weakself = self;
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.centerX.mas_equalTo(superView.mas_centerX);
        make.centerY.mas_equalTo(superView.mas_centerY);
        
    }];
    [self.leftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
       
       make.centerY.mas_equalTo(superView.mas_centerY);
       make.right.mas_equalTo(weakself.titleLabel.mas_left).mas_offset(-8);
       
   }];
    [self.rightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.centerY.mas_equalTo(superView.mas_centerY);
        make.left.mas_equalTo(weakself.titleLabel.mas_right).mas_offset(8);
        
    }];
}

- (UIImageView *)leftImageView{
    
    if (!_leftImageView) {
        
        _leftImageView = [[UIImageView alloc] init];
        _leftImageView.image = [UIImage imageNamed:@"line_49"];
        
        [self addSubview:_leftImageView];
    }
    
    return _leftImageView;
}

- (UIImageView *)rightImageView{
    
    if (!_rightImageView) {
        
        _rightImageView = [[UIImageView alloc] init];
        _rightImageView.image = [UIImage imageNamed:@"line"];
        
        [self addSubview:_rightImageView];
    }
    
    return _rightImageView;
}

- (UILabel *)titleLabel{
    
    if (!_titleLabel) {
        
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.text = @"产品列表";
        [_titleLabel setFont:[UIFont systemFontOfSize:14.f]];
        _titleLabel.textColor = [UIColor colorWithHexString:@"#444444"];
        [self addSubview:_titleLabel];
        
    }
    
    return _titleLabel;
}
@end
